home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
admin
/
linuxcon.000
/
linuxcon
/
linuxconf-1.6
/
translate
/
anlparm.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-04-07
|
1KB
|
47 lines
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "../misc/misc.h"
/*
Read argument from a file.
This function is used for DOS (Ya, this kit is used on DOS, not linuxconf)
to go around the command line length limitation.
Return the number of argument placed in newargv[].
It reads the argument and whenever one start with a @, it assumes
the argument is a file containing arguments.
*/
int anlparm (int argc, char *argv[], char *newargv[])
{
int ret = 0;
for (int i=0; i<argc; i++){
if (argv[i][0] == '@'){
FILE *fin = fopen (argv[i]+1,"r");
if (fin == NULL){
fprintf (stderr,"Ne peut ouvrir %s (%s)\n"
,argv[i]+1,strerror(errno));
}else{
char buf[300];
while (fgets(buf,sizeof(buf)-1,fin)!=NULL){
char *pt = buf;
while (1){
pt = str_skip (pt);
if (*pt == '\0') break;
char word[300];
pt = str_copyword (word,pt);
newargv[ret++] = strdup (word);
}
}
fclose (fin);
}
}else{
newargv[ret++] = argv[i];
}
}
newargv[ret] = NULL;
return ret;
}